[quartz] Fix manual resizing of windows
authorKristian Rietveld <kris@lanedo.com>
Sun, 19 Feb 2012 15:08:26 +0000 (16:08 +0100)
committerKristian Rietveld <kris@lanedo.com>
Tue, 10 Apr 2012 19:54:03 +0000 (21:54 +0200)
In the Quartz backend, there are two methods by which windows are
resized. The first method is fully handled by Quartz and does not appear
in the event stream the application resizes. The second method is when
we resize windows by ourselves. In OS X this happens when a GTK+ resize
grip is used. This resize grip is larger than the Quartz resize grip.
When the resize is started outside the "Quartz area", we have to handle
it by ourselves.

This patch fixes this manual window resizing by ignoring events while we
are in the process of resizing (such that the events actually arrive at
the sendEvent handler of GdkQuartzWindow where this resize is handled).
When the resize has finished we break all grabs such that GDK is not
stuck thinking the cursor is still in the resize window.

gdk/quartz/GdkQuartzNSWindow.c
gdk/quartz/GdkQuartzNSWindow.h
gdk/quartz/gdkevents-quartz.c

index fafc2a823801a5b545ca0ead28e61afe4626579d..76a759ccc00824eefb941ebc4fb750fc20c9918d 100644 (file)
   switch ([event type])
     {
     case NSLeftMouseUp:
+    {
+      double time = ((double)[event timestamp]) * 1000.0;
+
+      _gdk_quartz_events_break_all_grabs (time);
       inManualMove = NO;
       inManualResize = NO;
       inMove = NO;
       break;
+    }
 
     case NSLeftMouseDragged:
       if ([self trackManualMove] || [self trackManualResize])
   return YES;
 }
 
+-(BOOL)isInManualResize
+{
+  return inManualResize;
+}
+
 -(void)beginManualMove
 {
   NSRect frame = [self frame];
index df691ffe18a604e1208b339c3b08bb947985ad01..b456ff7c71bf7aa9ec80531d42cbcf49edc31ae3 100644 (file)
@@ -36,6 +36,7 @@
 -(BOOL)isInMove;
 -(void)beginManualMove;
 -(BOOL)trackManualMove;
+-(BOOL)isInManualResize;
 -(void)beginManualResize;
 -(BOOL)trackManualResize;
 -(void)showAndMakeKey:(BOOL)makeKey;
index 3cb249f1bcaa04458725d12cb1ab0270e1ecac2f..94064c0de960f6f62610398a78a92739df6aa79c 100644 (file)
@@ -1241,6 +1241,12 @@ gdk_event_translate (GdkEvent *event,
       return FALSE;
     }
 
+  /* Also when in a manual resize, we ignore events so that these are
+   * pushed to GdkQuartzWindow's sendEvent handler.
+   */
+  if ([(GdkQuartzWindow *)nswindow isInManualResize])
+    return FALSE;
+
   /* Find the right GDK window to send the event to, taking grabs and
    * event masks into consideration.
    */